<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>腾讯地址信息获取</title>
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    #mapPage {
      position: absolute;
    }
  </style>
  <!--
    腾讯位置转换为百度位置
    总结： 坑。
  -->
</head>
<body>
<iframe id="mapPage" width="100%" height="100%" frameborder=0
        src="http://apis.map.qq.com/tools/locpicker?search=1&type=1&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp">
</iframe>
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="http://api.map.baidu.com/api?v=2.0&ak=XCysCips5YQngYwbVCNH8Gxp6ezO9Yw2"></script>
<script>
  window.addEventListener('message', function (event) {
    var loc = event.data;
    if (loc && loc.module == 'locationPicker') {
       dd(loc.latlng);
      // zh(loc.latlng.lng, loc.latlng.lat);

      console.log(loc);
      alert(JSON.stringify(loc));
    }
  }, false);

  // 百度转换地址
  function dd(loc) {
    var ggPoint = new BMap.Point(loc.lng, loc.lat);
    var convertor = new BMap.Convertor();
    var pointArr = [];
    pointArr.push(ggPoint);
    convertor.translate(pointArr, 3, 5, function (data) {
      var point = new BMap.Point(data.points[0].lng, data.points[0].lat);
      var gc = new BMap.Geocoder();
      gc.getLocation(point, function (rs) {
        console.log(rs);
        alert(JSON.stringify(rs).replace(/"/g, ''));
      });
    }, 1000);
  }


  /**
   * 请求疼迅进行格转换规则
   */
  function zh(lng, lat) {
    $.ajax({
      type: 'get',
      url: 'http://apis.map.qq.com/ws/coord/v1/translate',
      data:{
        locations: lat +','+ lng,
        type: 3,
        key: 'DDLBZ-BTYK6-2S5SZ-MVCUJ-CQQUT-HSFCZ',
        output: 'jsonp',
        callback: 'function1'
      },
      dataType: 'jsonp',
      success: function (data) {
        console.log(data.locations[0]);

        var lat = data.locations[0].lat;
        var lng = data.locations[0].lng;

        //
        var point = new BMap.Point(lng, lat);
        var gc = new BMap.Geocoder();
        gc.getLocation(point, function (rs) {
          console.log(rs);
          alert(JSON.stringify(rs).replace(/"/g, ''));
        });
        //
      }
    });
  }


</script>
</body>
</html>